package lesson4.api.helpers;

import static lesson4.api.ApplicationManager.SITE_URL;
import lesson4.api.ApplicationManager;
import lesson4.pages.IndexPage;
import lesson4.pages.RegistrationPage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class NavigationHelper
{
	// Logger
	private static Logger log = LoggerFactory.getLogger(NavigationHelper.class);
	// Application manager instance
	private final ApplicationManager app;

	public NavigationHelper(ApplicationManager p_app)
	{
		app = p_app;
	}

	public IndexPage toIndexPage()
	{
		app.driver.manage().deleteAllCookies();
		toPage(app.page().indexPage().getPage());

		return app.page().indexPage();
	}

	public RegistrationPage toRegistrationPage()
	{
		toPage(app.page().registrationPage().getPage());

		return app.page().registrationPage();
	}

	public void toPage(String p_page)
	{
		log.info("Go to page: " + app.testPage + ": " + p_page);
		app.driver.get(SITE_URL + p_page);
	}
}
